home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
nw3bug.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-12
|
5KB
|
165 lines
/*
08-12-91
This code demonstrates what I believe is a bug in Netware 3.11. The bug keeps
NetWare from correctly reporting file access violations on file to which I have
only read access. The bug occurs when the file is opened. I've included a copy
of a session that demonstrates the bug.
1. F:\USR\MTSJMC>bcc nw3bug.c
Borland C++ Version 2.0 Copyright (c) 1991 Borland International
nw3bug.c:
Turbo Link Version 4.0 Copyright (c) 1991 Borland International
Available memory 286592
2. F:\USR\MTSJMC>dir >testfile
3. F:\USR\MTSJMC>nw3bug testfile
Opened testfile for read-only (r) access.
Opened testfile for read-write (r+) access.
Opened testfile for write (w) access.
Created (w+) testfile.
4. F:\USR\MTSJMC>dir >testfile
5. F:\USR\MTSJMC>flag testfile ro
TESTFILE [ Ro - A - - -- - - -- -- -- DI RI ]
6. F:\USR\MTSJMC>nw3bug testfile
Opened testfile for read-only (r) access.
Opened testfile for read-write (r+) access.
Opened testfile for write (w) access.
Created (w+) testfile.
7. F:\USR\MTSJMC>del testfile
Access denied
8. F:\USR\MTSJMC>c:
9. C:\>dir >testfile
10. C:\>attrib testfile +r
11. C:\>f:nw3bug testfile
Opened testfile for read-only (r) access.
Cannot open testfile for read-write (r+) access.
Cannot open testfile for write (w) access.
Cannot create (w+) testfile.
Step 1 compiles NW3BUG.C (this file) to NW3BUG.EXE using Borland C++ version
2.0. This is VERY generic code, so no ANSI C compiler should have any trouble
with it.
Step 2 generates a test file called TESTFILE in my file space on our file
server.
Step 3 shows a run of NW3BUG on a normal test file. The results it shows are
correct.
Steps 4, 5, and 6 recreate the test file, make it a read-only file, and run
NW3BUG on the new test file. The results are the same as those of step 3. This
is NOT correct.
Step 7 demonstrates that TESTFILE realy is a read-only file and is protected
against deletion. If you do a TYPE on TESTFILE at this point, you will see that
its contents were not wiped out as they were reported to be in the fourth
message of step 6.
Steps 8, 9, and 10 change the current drive to by local hard disk, create a new
test file there, and make it a read-only file.
Step 11 shows how NW3BUG behaves with a read-only file on a DOS volume. These
results are different from those shown in step 6 and are correct.
My conclusion from this experiment is that NetWare does not report file access
violations the way that DOS does. The session above shows only one of the tests
I ran. Other experiments involved a read-write file that had been placed into a
directory to which I had no write access, tests on DOS without any network
drivers loaded at all, and using different network drivers (NET4 rather than my
usual XMSNET4). All the results pointed to the same bug in NetWare. I would be
interested to hear of your own experiments involving NW3BUG or a similar
program of your own creation.
To be reasonable, it is concievable that I have something set incorrectly in my
SHELL.CFG file, so here's a copy of it:
SHORT MACHINE TYPE = IBM
LONG MACHINE TYPE = IBM
LOCAL PRINTERS = 0
SEARCH MODE = 1
SHARE = ON
TASK MODE = 0
SPX ABORT TIMEOUT = 2000
show dots = on
preferred server = ccmts
System configuration:
IBM PS/2 model 55sx
IBM DOS 4.01
IPX version 3.02 with IBM Token Ring driver version 2.61
XMSNET3 version 3.01
File server:
IBM PS/2 model 80
NetWare 3.11
I realize that running this experiment takes time and that the people who
are capable of running this experiment are very likely to have plenty work
to do as it is. So let me thank you in advance for your time and talent.
Jeff Clough
System Communications Analyst (==Programmer)
Georgia State University Computer Center
CIS: 76264,2073
Voice: 404-651-2639
FAX: 404-651-4579
*/
#include <stdio.h>
int main(int argc,char **argv) {
FILE *f;
if (argc<2) {
puts("Pass a filename of the command line.");
return 1;
}
/* Open the file for read-only access.
*/
if ((f=fopen(*++argv,"r"))==0)
printf("Cannot open %s for read-only (r) access.\n",*argv);
else {
printf("Opened %s for read-only (r) access.\n",*argv);
fclose(f);
}
/* Open the file for read-write access.
*/
if ((f=fopen(*argv,"r+"))==0)
printf("Cannot open %s for read-write (r+) access.\n",*argv);
else {
printf("Opened %s for read-write (r+) access.\n",*argv);
fclose(f);
}
/* Open the file for write access.
*/
if ((f=fopen(*argv,"w"))==0)
printf("Cannot open %s for write (w) access.\n",*argv);
else {
printf("Opened %s for write (w) access.\n",*argv);
fclose(f);
}
/* Create (or recreate) the file.
*/
if ((f=fopen(*argv,"w+"))==0)
printf("Cannot create (w+) %s.\n",*argv);
else {
printf("Created (w+) %s.\n",*argv);
fclose(f);
}
return 0;
}